class DomFn{
	$(selector) {
		var type = selector.substring(0, 1);
		if (type === '#') {
			if (document.querySelector) {
				return document.querySelector(selector);
			} else {
				return document.getElementById(selector.substring(1))
			}
		} else if (type === '.') {
			if (document.querySelectorAll) {
				return document.querySelectorAll(selector);
			} else {
				return document.getElementsByClassName(selector.substring(1))
			}
		} else {
			return document['querySelectorAll' ? 'querySelectorAll' : 'getELementsByTagName'](selector);
		}
	}
	/*检测类名*/
	hasClass(ele, name) {
		return ele.className.math(new RegExp('(\\s|^' + name + '(\\s|$)'));
	}
	/*添加类名*/
	addClass(ele, name) {
		if (!this.hasClass(ele, name)) {
			ele.className += '' + name;
		}
	}
	/*删除类名*/
	removeClass(ele, name) {
		if (this.hasClass(ele, name)) {
			var reg = new RegExp('(\\s|^)' + name + '(\\s|$)');
			ele.className = ele.className.replace(reg, '');
		}
	}
	/*替换类名*/
	replaceClass(ele, newName, oldName) {
		this.removeClass(ele, oldname);
		this.addClass(ele, newName);
	}
	/*获取兄弟节点*/
	siblings(ele) {
		console.log(ele.parentNode);
		var child = ele.parentNode.children;
		var eleMatch = [];
		let len = child.length;
		for (let i = 0;i < len; i++) {
			if (child[i] != ele) {
				eleMatch.push(child[i]);
			}	
		}
		return eleMatch;
	}
	/*获取兄弟节点*/
	getBystyle(obj, name) {
		if (obj.currentStyle) {
			return obj.currentStyle[name];
		} else {
			return getComputedStyle(obj, false)[name];
		}
	}
}